projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9ad5a00
)
i2c: mv_i2c.c: Validate read length in I2C command
author
jinghua
<
[email protected]
>
Fri, 16 Sep 2016 13:07:54 +0000
(15:07 +0200)
committer
Heiko Schocher
<
[email protected]
>
Mon, 26 Sep 2016 08:42:56 +0000
(10:42 +0200)
The I2C bus will get stuck when reading 0 byte. So we add validation of
the read length in i2c_read(). This issue only occurs on read operation.
Signed-off-by: jinghua <
[email protected]
>
Signed-off-by: Stefan Roese <
[email protected]
>
Cc: Nadav Haklai <
[email protected]
>
Cc: Kostya Porotchkin <
[email protected]
>
Cc: Wilson Ding <
[email protected]
>
Cc: Victor Gu <
[email protected]
>
Cc: Hua Jing <
[email protected]
>
Cc: Terry Zhou <
[email protected]
>
Cc: Hanna Hawa <
[email protected]
>
Cc: Haim Boot <
[email protected]
>
Cc: Heiko Schocher <
[email protected]
>
drivers/i2c/mv_i2c.c
patch
|
blob
|
history
diff --git
a/drivers/i2c/mv_i2c.c
b/drivers/i2c/mv_i2c.c
index 291b2d7e68c7557c431e07596684577841e7fa1e..7f52fa2d858bf42fc5b6cd4d95030d9ff1193bbd 100644
(file)
--- a/
drivers/i2c/mv_i2c.c
+++ b/
drivers/i2c/mv_i2c.c
@@
-243,6
+243,11
@@
static int __i2c_read(struct mv_i2c *base, uchar chip, u8 *addr, int alen,
debug("i2c_read(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
"len=0x%02x)\n", chip, *addr, alen, len);
+ if (len == 0) {
+ printf("reading zero byte is invalid\n");
+ return -EINVAL;
+ }
+
i2c_reset(base);
/* dummy chip address write */